# $Id: PKGBUILD 83477 2013-02-01 16:58:18Z kkeen $
# Maintainer: Kyle Keen <keenerd@gmail.com>
# Contributor: Michael Düll <mail@akurei.me>

pkgname=rtl-sdr
pkgver=20130201
_commit="ea4dbd242d268e50163acb8df1ac662485b43632"
pkgrel=1
pkgdesc="Driver for Realtek RTL2832U, allowing general purpose software defined radio (SDR)."
arch=('i686' 'x86_64')
url="http://sdr.osmocom.org/trac/wiki/rtl-sdr"
license=('GPL')
depends=('libusb>=1.0')
makedepends=('git' 'cmake')
conflicts=('rtl-sdr-git')

_gitroot="git://git.osmocom.org/rtl-sdr.git"
_gitname="rtl-sdr"

build() {
  cd "$srcdir"
  msg "Connecting to GIT server...."

  if [[ -d "$_gitname" ]]; then
    cd "$_gitname" && git pull origin
    msg "The local files are updated."
  else
    git clone "$_gitroot" "$_gitname"
  fi

  msg "GIT checkout done or server timeout"
  msg "Starting build..."

  rm -rf "$srcdir/$_gitname-build"
  git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
  cd "$srcdir/$_gitname-build/"
  git checkout "$_commit"

  mkdir build
  cd build
  cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -Wno-dev ../
  make
}

package() {
  cd "$srcdir/$_gitname-build/build/"
  make DESTDIR="$pkgdir" install
  install -D -m644 "$srcdir/$_gitname-build/rtl-sdr.rules" "$pkgdir/usr/lib/udev/rules.d/10-rtl-sdr.rules"
}

# vim:set ts=2 sw=2 et:
